<?
defined('SYSPATH') OR die('No direct access allowed.');

class Test_Controller extends Controller 
{
  public function index()
  {
    $page = new View('test');
    echo $page->render();	
  }
  
  public function view($id=1)
  { 
	$article=new Article_Model($id);
	if($article->id== '' )
		Event::run('system.404');
 
	echo '<h1>'.$article->title.'</h1>';
	echo ''.$article->text.'';
  }
  
  function insert($title='test', $text='testtext')
  {
	/*$form=new Forge();
	$form->input('title')->label(true);
	$form->textarea('text')->label(true);
	$form->submit('Submit');
 
	if($form->validate())
	{*/
		$article=new Article_Model();
		$article->title=$title;
		$article->text=$text;
		if($article->save())
		{
			echo 'Saved';
		}
	/*}
	else
	{
	echo $form->html();
	}*/
  }
  function get($id)
  {
    echo 'get';
  }
  
  function add()
  {
    $author = new Author_Model('authors');
    $author->name = $this->input->post('author_name','?');
    $author->save();
    echo $author->name;
  }
}
?>